# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=virt-viewer
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=8.0
pkgrel=1
arch=('any')
pkgdesc="Displaying the graphical console of a virtual machine (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-spice-gtk"
         "${MINGW_PACKAGE_PREFIX}-gtk-vnc"
         "${MINGW_PACKAGE_PREFIX}-libvirt"
         "${MINGW_PACKAGE_PREFIX}-libxml2"
         "${MINGW_PACKAGE_PREFIX}-opus")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "gtk-doc"
             "${MINGW_PACKAGE_PREFIX}-icoutils")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://virt-manager.org/"
source=("https://virt-manager.org/download/sources/virt-viewer/virt-viewer-${pkgver}.tar.gz")
sha256sums=('dcf358ed5d7a4900215133135a6492c04311d84332816d930df9a89d6195b6ed')

prepare() {
  cd $srcdir/${_realname}-${pkgver}
}

build() {
  [[ -d ${srcdir}/build-${MINGW_CHOST} ]] && rm -rf ${srcdir}/build-${MINGW_CHOST}
  mkdir -p "${srcdir}/build-${MINGW_CHOST}" && cd "${srcdir}/build-${MINGW_CHOST}"

  ../${_realname}-${pkgver}/configure \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --with-spice-gtk

  make
}

package() {
  cd "$srcdir/build-${MINGW_CHOST}"
  make DESTDIR=$pkgdir install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}/COPYING"
}
